<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class GrowController extends Controller
{
    

    //生成受益,grows账单是给用户看的
    public function payrun() {
    	$today = date('Y-m-d'); //现获取今天的日期

    	//在tasks中,大于今天日起的,都会有收益
    	$task = DB::table('tasks')->where('enddate','>=',$today)->get();

    	/*循环为每个人写入收益信息*/
    	foreach($task as $t) {
    		$t = (array)$t;
    		$t['paytime'] = $today; //收益时间
    		unset($t['tid']);
    		unset($t['enddate']);
    		DB::table('grows')->insert($t);
    	}
    }

   
    
}
